import {get, post} from '@/http/axios'

export default {
    namespaced: true,
    state: {
        hospitals:[]
    },
    mutations: {
        refreshQueryHospitals(state,data) {
            state.hospitals = data
        }
    },
    actions: {
        // 删除
        async deleteHospital({dispatch},id) {
            let response = await get("/hospital/deleteById",id)
            return response.data
        },
        // 保存
        async saveOrUpdateHospital({commit},params) {
            let response = await post("/hospital/saveOrUpdate",params)
            return response.data
        },
        // 分页查询所有医院
        async queryHospitals({commit},params) {
            let response = await get("hospital/pageQuery",params)
            console.log(response.data.data.list)
            commit("refreshQueryHospitals",response.data.data)
        }
    }
}